#include<stdio.h>
class A
{
    public:
        virtual void display(){printf("display A\n");}
};
class B:public A
{
    public:
        void display(){printf("display B\n");}
};
class C:public B
{
    public:
        void display(){printf("display C\n");}
};
void func(A *x)
{
    x->display();
}
int main(int argc, char *argv[])
{
    A a, *p;
    B b;
    C c;
    p = &a;
    func(p);
    p = &b;
    func(p);
    p = &c;
    func(p);
    return 0;
}
